package com.sp.scmdb.action;

import java.io.InputStream;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.sp.scmdb.bean.MapBean;
import com.sp.scmdb.common.CommonParamter;
import com.sp.scmdb.common.action.BaseAction;
import com.sp.scmdb.entity.Map;
import com.sp.scmdb.webservice.service.UploadMapService;

@Controller("uploadMapAction")
@Scope("prototype")
public class UploadMapAction extends BaseAction<MapBean> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static Log log = LogFactory.getLog(UploadMapAction.class);
	
	private UploadMapService mapService;
	private InputStream imagStream;

	@SuppressWarnings("unchecked")
	public String findAll() {
		try{
			List<Map> mapList = mapService.queryIsUsed();
			entity.setAllList(mapList);
			entity.setList(mapList.subList(entity.getCurrentRow(), entity.getLastRow()));
			session.put("useType", CommonParamter.TypeCommon.getMapUseType());
		}catch(Exception e){
			log.error("findAll fail!reason:" + e.getMessage());
		}
		return SUCCESS;
	}
	
	public String uploadMap(){
		String result = mapService.uploadMap();
		//request.setAttribute("message", result);
		messageSession("0", result);
		return "upload";
	}
	
	public InputStream getImagStream() {
		return imagStream;
	}

	public void setImagStream(InputStream imagStream) {
		this.imagStream = imagStream;
	}

	public void setMapService(UploadMapService mapService) {
		this.mapService = mapService;
	}
}
